package br.webchild.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceDateField;
import com.smartgwt.client.data.fields.DataSourceSequenceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.calendar.Calendar;
import com.smartgwt.client.widgets.form.fields.HeaderItem;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.ViewLoader;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;

public class Agenda extends Window {

	public Agenda() {
		this.setTitle("Agenda");
		this.setWidth("100%");
		this.setHeight("100%");
		this.setIsModal(true);
		this.setShowMinimizeButton(false);
		
		VLayout layout = new VLayout();
		addItem(layout);
		ToolStrip menu_calendario = new ToolStrip();
		menu_calendario.setWidth("100%");
		layout.addMember(menu_calendario);
		
        DataSource eventDS = new DataSource();  
        DataSourceSequenceField eventIdField = new DataSourceSequenceField();
        eventIdField.setTitle("eventIdField");
        eventIdField.setPrimaryKey(true);  
  
        DataSourceTextField nome = new DataSourceTextField();
        nome.setTitle("Nome");
        
        DataSourceTextField descricao = new DataSourceTextField();
        descricao.setTitle("Descricao");
        
        DataSourceDateField data_inicial = new DataSourceDateField();
        data_inicial.setTitle("Data Inicial");
        data_inicial.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE);
        
        DataSourceDateField data_final = new DataSourceDateField();  
        data_final.setTitle("Data Final");
        data_final.setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE);
        
        eventDS.setFields(eventIdField, nome, descricao, data_inicial, data_final);  
        eventDS.setClientOnly(true);  
//        eventDS.setTestData(CalendarData.getRecords());  
  
        Calendar calendar = new Calendar();  
        calendar.setDataSource(eventDS);  
        calendar.setAutoFetchData(true);  
  
        //specify the last field from the default fields so that subsequent fields come after the  
        //default fields  
        TextItem descItem = new TextItem();  
        descItem.setName("descItem");  
  
        //custom fields below  
        HeaderItem eventOptions = new HeaderItem();  
        eventOptions.setDefaultValue("Event Options");  
  
  
        SelectItem reminderItem = new SelectItem();  
        reminderItem.setName("reminderType");  
        reminderItem.setTitle("Reminder");  
        reminderItem.setWidth(70);  
        reminderItem.setDefaultToFirstOption(true);  
        reminderItem.setValueMap("Pop-up", "Email");  
  
        TextItem reminderValue = new TextItem();  
        reminderValue.setName("reminderValue");  
        reminderValue.setShowTitle(false);  
        reminderValue.setWidth(60);  
        reminderValue.setDefaultValue(10);  
  
  
        calendar.setEventEditorFields(descItem, eventOptions,reminderItem, reminderValue); 
  
        TextItem nameItem = new TextItem();  
        nameItem.setType("nameitem");  
        nameItem.setName("name");  
  
        RadioGroupItem radioGroupItem = new RadioGroupItem("sharing");  
        radioGroupItem.setTitle("radioGroupItem");  
        radioGroupItem.setVertical(false);  
        radioGroupItem.setValueMap("Public", "Private");  
        radioGroupItem.setWidth(50);  
          
        calendar.setEventDialogFields(nameItem, radioGroupItem);  
  
        calendar.draw();  
     
		layout.addMember(calendar);
		this.centerInPage();
		
	}
}
